﻿/// <reference path="JSintellisense/jquery-1.3.2-vsdoc2.js" />
var map = null;
var geocoder = null;
var marker = null;
var center = null;
var lat_lng_all = "";
var latlng_array = null;
var gzoom = 17;
var myadd = "";
var mylabel = null;
var adds = null;
var myIcon = new BMap.Icon("/images/deliver_map.png?v=1", new BMap.Size(32, 32), { anchor: new BMap.Size(10, 0) });

function initialize() {


    var json = eval("(" + $("#hflatlng").val() + ")");
    var _lat = json.ulat;
    var _lng = json.ulng;
    if (_lat == "0" || _lng == "0") {
        return;
    }

    map = new BMap.Map("map_canvas");
    map.enableScrollWheelZoom();

  

    center = new BMap.Point(_lng, _lat);
    map.addControl(new BMap.NavigationControl());

    marker = new BMap.Marker(center, { title: '我的位置' });
    map.addOverlay(marker);
  

    


    //创建商家
    var shopmarker = new BMap.Point(json.slng, json.slat);
   // var myIcon = new BMap.Icon("/images/shopico.png", new BMap.Size(46, 40));
   // var marker2 = new BMap.Marker(shopmarker, { icon: myIcon });  // 创建标注
    var marker2 = new BMap.Marker(shopmarker);  // 创建标注
    map.addOverlay(marker2);              // 将标注添加到地图中

    map.centerAndZoom(center, gzoom);
    var walking = new BMap.WalkingRoute(map, { renderOptions: { map: map, autoViewport: true } });
    walking.search(shopmarker, center);



    //配送员
    var hfdeliverlatlng = $("#hfdeliverlatlng").val()+"";
    if (hfdeliverlatlng.length > 0) {
        var json = JSON.parse(hfdeliverlatlng);
        var shopmarker = new BMap.Point(json[0].JH2, json[0].JH3);
        var myIcon = new BMap.Icon("/images/deliverico.png", new BMap.Size(46, 40));
        var marker2 = new BMap.Marker(shopmarker, { icon: myIcon });  // 创建标注
        map.addOverlay(marker2);
    }
    


    return false;
}




//定位相关类
$(function () {
    initialize();
})


